<template>
    <div id="IM0501Detail" class="mt20">
        <div class="formEmbedTable">
            <table>
                <tr>
                    <td>Transaction Sequence No.</td>
                    <td> {{toDetail.flowNo}} </td>				
                </tr>
                <tr>	
                    <td>Submit</td>
                    <td> {{toDetail.userAlias}} </td>			
                </tr>
            </table>
        </div>
        <div class="formEmbedTable mt20 ">
            <table>
               <caption>Accoun Limit</caption>
                <tr>
                    <td>Account No.：</td>
                    <td> {{detailData.accNo}} </td> 
                    <td>Account Name：</td>
                     <td> {{detailData.accName}} </td>       			
                </tr>
                <tr>
                    <td>custom type：</td>
                    <td> {{detailData.cstType==0?"private":"company"}} </td>
                    <td >Limit Type：</td>
                    <td > {{$tools.dict.getLimitType(detailData.limitType)}} </td>      			
                </tr>
                <tr>
                    <td>Channel：</td>
                    <td> {{detailData.paramChannel}} </td> 
                    <td>Currency：</td>
                     <td> {{detailData.currType}} </td>       			
                </tr>
                <tr>
                    <td>Single Limit：</td>
                    <td> {{detailData.limitSingle}} </td> 
                    <td >Daily Limit：</td>
                    <td > {{detailData.limitDay}} </td>      			
                </tr>
                <tr>
                    <td>Daily amount Limit：</td>
                    <td> {{detailData.dayNum}} </td> 
                    <td >Year Limit：</td>
                    <td > {{detailData.limitYear}} </td>      			
                </tr>
            </table>
        </div>
        <div class="btnArea mt20 tac">
            <el-button type="primary" @click="agree()">Approve</el-button>
            <el-button type="primary" @click="dialogTableVisible=true">Reject</el-button>
            <el-button type="primary" icon="close" @click="back">Back</el-button>
        </div>
        <!--拒绝页面弹窗-->
        <el-dialog :visible.sync="dialogTableVisible" :close-on-click-modal="false" :close-on-press-escape="false">
            <el-form ref="rejectForm" :model="rejectForm" class="formEmbedTable">
                <table>
                    <caption>Refusal reason</caption>
                    <tr>
                        <td>Refusal reason</td>
                        <td>
                            <el-form-item prop="rejReason">
                                <el-input placeholder="input Refusal reason" v-model="rejectForm.rejReason"></el-input>
                            </el-form-item>
                        </td>
                    </tr>
                </table>
                <div class="btnArea mt20 tac">
                    <el-button type="primary" @click="dialogTableVisible = false,reject()">Confirm</el-button>
                    <el-button @click="dialogTableVisible=false">Back</el-button>
                </div>
            </el-form>
        </el-dialog>
        <!--拒绝页面弹窗end-->
    </div>
</template>
<script>
 import ghbIcon from '@src/components/icon'
    export default {
        name:'IM0501Detail',
        components:{
            //ghbIcon
        },
        props:['detailData','toDetail',],
        mounted(){
            console.log("detailData:"+JSON.stringify(this.detailData))
             console.log("toDetail:"+JSON.stringify(this.toDetail))
        },
        data(){
            return{
                rejectForm:{//审核拒绝列表
                    bsnAuthList:[],authFlag:'1',rejReason:'',
                },
                agreeForm:{
                    bsnAuthList:[],authFlag:'0',
                },
                dialogTableVisible:false,
            }
        },
        methods:{
            agree(){
               //判断是否选中数据
               console.log("toDetail"+JSON.stringify(this.toDetail))
                this.agreeForm.bsnAuthList.push(this.toDetail);
                console.log("agreeForm"+JSON.stringify(this.agreeForm))
                this.$tools.request(this,this.toDetail.bsnCode+"AuthAction.do",this.agreeForm).then(data=>{
                    //console.log("data"+JSON.stringify(data))
                    if(data.body.errorCode==0){
                        this.$alert("success","success",{
                            confirmButtonText: 'Confirm',
                            callback: action => {
                                //刷新审核页面
                                this.$emit("back")
                            }
                        })
                    }else{
                        this.$alert("System Error Try again", "warning",{
                            confirmButtonText: 'Confirm',
                            callback: action => {
                            }
                        })
                    }
                })
            },
            reject(){
                this.rejectForm.bsnAuthList.push(this.toDetail);
                console.log("rejectForm"+JSON.stringify(this.rejectForm))
                this.$tools.request(this,this.toDetail.bsnCode+"AuthAction.do",this.rejectForm).then(data=>{
                    if(data.body.errorCode==0){
                        this.$alert("Success","warning ",{
                            confirmButtonText: 'Confirm',
                            callback: action => {
                                //刷新审核页面
                                this.$emit("back")
                            }
                        })
                    }else{
                        this.$alert("System Error Try again", "warning",{
                            confirmButtonText: 'Confrim',
                            callback: action => {
                            }
                        })
                    }
                })
            },
            back(){
                this.$emit("back")
            },
            
        }
    }
</script>